package com.elephant.leil.generator.model;

import com.elephant.leil.generator.utils.StringConvertUtils;

import java.util.List;

/**
 * 数据表模型
 */
public class TableModel {

    /**
     * 表名称
     */
    String tableName;

    /**
     * 表前缀
     */
    String prefix;

    /**
     * 表注释
     */
    String tableComment;

    /**
     * 首字母大写模块名称
     */
    String upperCamelModelName;

    /**
     * 驼峰法模块名称
     */
    String camelModelName;

    /**
     * 中划线模块名称
     */
    String middleLineModelName;

    /**
     * 字段列表
     */
    List<Column> columns;

    public TableModel(String tableName) {
        this.tableName = tableName;
        this.upperCamelModelName = StringConvertUtils.underlineToCamelUpperStart(tableName);
        this.camelModelName = StringConvertUtils.underlineToCamel(tableName);
        this.middleLineModelName = StringConvertUtils.underlineToMiddleLine(tableName);
    }

    public TableModel(String tableName, String prefix) {
        this.tableName = tableName;
        this.prefix = prefix;
        String tableNameWithoutPrefix = tableName.substring(this.prefix.length());
        this.upperCamelModelName = StringConvertUtils.underlineToCamelUpperStart(tableNameWithoutPrefix);
        this.camelModelName = StringConvertUtils.underlineToCamel(tableNameWithoutPrefix);
        this.middleLineModelName = StringConvertUtils.underlineToMiddleLine(tableNameWithoutPrefix);
    }

    public String getTableName() {
        return tableName;
    }

    public String getPrefix() {
        return prefix;
    }

    public String getUpperCamelModelName() {
        return upperCamelModelName;
    }

    public String getCamelModelName() {
        return camelModelName;
    }

    public String getMiddleLineModelName() {
        return middleLineModelName;
    }

    public String getTableComment() {
        return tableComment;
    }

    public void setTableComment(String tableComment) {
        this.tableComment = tableComment;
    }

    public List<Column> getColumns() {
        return columns;
    }

    public void setColumns(List<Column> columns) {
        this.columns = columns;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public void setUpperCamelModelName(String upperCamelModelName) {
        this.upperCamelModelName = upperCamelModelName;
    }

    public void setCamelModelName(String camelModelName) {
        this.camelModelName = camelModelName;
    }

    public void setMiddleLineModelName(String middleLineModelName) {
        this.middleLineModelName = middleLineModelName;
    }


    @Override
    public String toString() {
        return "TableModel{" +
                "tableName='" + tableName + '\'' +
                ", prefix='" + prefix + '\'' +
                ", tableComment='" + tableComment + '\'' +
                ", upperCamelModelName='" + upperCamelModelName + '\'' +
                ", camelModelName='" + camelModelName + '\'' +
                ", middleLineModelName='" + middleLineModelName + '\'' +
                ", columns=" + columns +
                '}';
    }
}
